<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/order.css?v=<?php echo Yii::app()->params['version']['CSS'];?>"/>
<div class="cont">
	<?php $this->beginWidget('application.widget.tools.process', array('step'=>1)); ?>
	<?php $this->endWidget(); ?>
    <div class="order_confirm">
    	<h2>确认您的订单信息 :</h2>
        <table class="order_tit" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <th width="400">产品名称</th>
            <td width="105">出行人数</td>
            <td width="135">出发日期</td>
            <td>价格</td>
          </tr>
        </table>
        <div class="brief fr">
        	<i class="bg_t"></i>
            <h2>人数与价格（含税）</h2>
            <table border="0" cellspacing="0" cellpadding="0">
              <thead>
              	<tr>
              	  <th>成 人</th>
              	  <td>
				  <span>￥ <?php echo number_format($produce['price']);?></span>x<?php echo $personInfo['quantity'];?></td>
              	</tr>
              </thead>
              <tbody>
              	<!--<tr>
              	  <th>Cindy</th>
              	  <td><span>￥ 695</span>x3</td>
              	</tr>
              	<tr>
              	  <th>爱跑的ik</th>
              	  <td><span>￥ 2650</span>x3</td>
              	</tr>
              	<tr>
              	  <th>cimao</th>
              	  <td><span>￥ 2690</span>x3</td>
              	</tr>-->
              </tbody>
              <tfoot>
              	<tr>
              	  <th>合计：</th>
              	  <td><span>￥ <?php echo number_format($produce['price']*$personInfo['quantity'], 2);?></span></td>
              	</tr>
              </tfoot>
            </table>
            <i class="bg_b"></i>
        </div>
        <div class="pro_info">
        	<div class="info fl">
            	<a href=""><img src="<?php echo $produce["image"];?>" alt="<?php echo $produce['goods_name'];?>" /></a>
                <p><a href=""><?php echo $produce['goods_name'];?></a></p>
            </div>
            <p class="people fl">成人<?php echo $personInfo['quantity'];?>人</p>
            <p class="date fl"><?php echo $personInfo['dateval'];?></p>
            <div class="rate fl">
            	<strong>￥ <?php echo $produce['price'];?></strong>
                <a href="<?php echo Yii::app()->createUrl("trip/detail", array("goodssn"=>$produce['goods_sn']));?>">修改出行人数</a>
                <a href="<?php echo Yii::app()->createUrl("trip/detail", array("goodssn"=>$produce['goods_sn']));?>">修改出发日期</a>
            </div>
        </div>
        <!--可选服务模块-->
		<!--<?php $this->beginWidget('application.widget.tools.addService'); ?>
		<?php $this->endWidget(); ?>-->
        <div class="pas_info">
        	<h3>确认用户信息</h3>
            <p class="note"><b>*</b>请按护照准确填写，支付成功后我们按您填写的姓名拼音，性别出票，因个人信息填写错误产生的修改费需自行承担。</p>
            <dl>
				<?php for($i=1 ; $i <= $personInfo['quantity']; $i++){?>
            	<dd>
                	<table class="base" border="0" cellspacing="0" cellpadding="0">
                      <tr>
                        <th scope="col"><span><b>*</b>中文姓名</span></th>
                        <th scope="col"><b>*</b>姓氏（拼音）</th>
                        <th scope="col"><b>*</b>名字（拼音）</th>
                        <th scope="col"><b>*</b>性别</th>
                      </tr>
                      <tr>
                        <td><span>旅客 <?php echo $i;?>:</span><input type="text" name="passengerName" placeholder="例如：王小明" /></td>
                        <td><input type="text" name="passengerFirst" placeholder="例如：WANG" /></td>
                        <td><input type="text" name="passengerSecond" placeholder="例如：XIAOMING" /></td>
                        <td>
                        	<div class="select fl sex">
                                <p><span data-val="0" class="info">男</span><i></i></p>
                                <ul class="item">
                                    <li data-val="0">男</li>
                                    <li data-val="1">女</li>
                                </ul>
                            </div>
                        </td>
                      </tr>
                    </table>
                    <table class="detail" border="0" cellspacing="0" cellpadding="0">
                      <caption>
                        特别提醒 : 为了您的顺利出行，请确保旅行结束日期至少比证件期早6个月
                      </caption>
                      <tr>
                        <th scope="row"><b>*</b>证件号码：</th>
                        <td>
                        	<div class="select fl pass">
                                <p><span data-val="0" class="info">护照</span><i></i></p>
                                <ul class="item">
                                    <li data-val="0">护照</li>
                                    <li data-val="1">身份证</li>
                                </ul>
                            </div>
                            <input type="text" name="passport" class="t" />
                        </td>
                      </tr>
                      <tr>
                        <th scope="row"><b>*</b>出生日期：</th>
                        <td><input type="text" name="birthday" id="datepicker<?php echo $i;?>1" class="t" readonly="readonly" /></td>
                      </tr>
                      <tr>
                        <th scope="row"><b>*</b>证件有效期：</th>
                        <td><input type="text" name="validate" id="datepicker<?php echo $i;?>2" class="t" readonly="readonly" /></td>
                      </tr>
                      <tr>
                        <th scope="row"><b>*</b>手机号码：</th>
                        <td><input type="text" name="mobile" class="t" /></td>
                      </tr>
                    </table>
                </dd>
				<?php }?>
            </dl>
        </div>
        <p class="check">
        	<input type="checkbox" name="" id="confirm" checked="checked" /><label for="confirm">我已阅读并接受<a href="javascript:void(0);">《私家之旅网站用户服务条款》</a></label>
        </p>
        <a href="javascript:void(0);" class="buy">立即预定</a>
    </div>
</div>
<script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/assets/js/pikaday.js?v=<?php echo Yii::app()->params['version']['JS'];?>"></script>
<script type="text/javascript">
var goodsn = "<?php echo $produce['goods_sn'];?>";
<?php for($i=1 ; $i <= $personInfo['quantity']; $i++){?>
var picker = new Pikaday({
	field: document.getElementById('datepicker<?php echo $i;?>1'),
	firstDay: 1,
	minDate: new Date('1900-01-01'),
	maxDate: new Date('<?php echo date("Y-m-d");?>'),
	yearRange: [1900,<?php echo date("Y");?>]
});
var picker = new Pikaday({
	field: document.getElementById('datepicker<?php echo $i;?>2'),
	firstDay: 1,
	minDate: new Date('<?php echo date("Y-m-d");?>'),
	maxDate: new Date('<?php echo date("Y-m-d", strtotime("+21 year"));?>'),
	yearRange: [<?php echo date("Y");?>,<?php echo date("Y", strtotime("+21 year"));?>]
});
<?php }?>
//订单提交
$(".buy").on("click", function(){
	//添加用户信息
	var req = {info:{}, order:[]};
	var errListen = [];
	req.info = [];
	$("input[name=passengerName]").each(function(i){
		var val = $.trim($(this).val());
		if(val == ""){
			errListen.push("请输入完整姓名");
		}
		if(typeof req.info[i] == "undefined"){
			req.info[i] = {};
		}
		req.info[i].passenger_name = val;
	});
	$("input[name=passengerFirst]").each(function(i){
		var val = $.trim($(this).val());
		if(val == ""){
			errListen.push("请输入完整姓拼音");
		}
		req.info[i].passenger_first = val;
	});
	$("input[name=passengerSecond]").each(function(i){
		var val = $.trim($(this).val());
		if(val == ""){
			errListen.push("请输入完整名拼音");
		}
		req.info[i].passenger_second = val;
	});
	$(".select.sex").each(function(i){
		req.info[i].sex = $(this).find(".info").attr("data-val");
	});
	$(".select.pass").each(function(i){
		req.info[i].certification_type = $(this).find(".info").attr("data-val");
	});
	$("input[name=passport]").each(function(i){
		var val = $.trim($(this).val());
		if(val == ""){
			errListen.push("请输入完整证件信息");
		}
		req.info[i].certification_number = val;
	});
	$("input[name=birthday]").each(function(i){
		var val = $.trim($(this).val());
		if(val == ""){
			errListen.push("请输入完整出生日期");
		}
		req.info[i].birthday = val;
	});
	$("input[name=validate]").each(function(i){
		var val = $.trim($(this).val());
		if(val == ""){
			errListen.push("请输入完整证件有效期");
		}
		req.info[i].cartification_date = val;
	});
	$("input[name=mobile]").each(function(i){
		var val = $.trim($(this).val());
		if(val == ""){
			errListen.push("请输入完整手机号");
		}
		req.info[i].mobile = val;
	});
	if(errListen != ""){
		$.jGrowl(errListen[0]);
		return false;
	}
	//添加商品
	var format = cookie.getCookie(goodsn);
	var json = eval("(" + format + ")");
	var produce = {};
	produce.goods_sn = goodsn;
	produce.sell_num = json.quantity;
	req.order.push(produce);
	req.date = json.dateval;
	//表单提交
	var request = {};
	request.url = "<?php echo Yii::app()->createUrl('pay/book');?>";
	request.type = "post";
	request.dataType = "JSON";
	request.timeout = 5000;
	request.cache = false;
	request.data = req;
	request.error = function(){$.jGrowl("有点问题~");};
	request.beforeSend = function(){};
	request.success = function(msg){
		if(msg.header.status != 0){
			$.jGrowl(msg.header.reqMsg);
			return false;
		}
		location.href = msg.body.returnUrl;
	};
	request.complete = function(){};
	$.ajax(request);
});
</script>